import requests
import unittest
class TestLogin(unittest.TestCase):
    def test_login_01(self):
        resp = requests.post(url='http://ihrm2-test.itheima.net/api/sys/login',
                             headers={"Content-Type": "application/json"},
                             json={"mobile": "13800000002", "password": "123456"})
        self.assertEqual(200,resp.status_code)
        self.assertEqual(True,resp.json().get("success"))
        self.assertEqual(10000,resp.json().get("code"))
        self.assertEqual("操作成功！",resp.json().get("maeeage"))
    def test_login_02(self):
        resp = requests.post(url='http://ihrm2-test.itheima.net/api/sys/login',
                             headers={"Content-Type": "application/json"},
                             json={"mobile": "13800000002", "password": "1234567"})
        self.assertEqual(200,resp.status_code)
        self.assertEqual(False,resp.json().get("success"))
        self.assertEqual(20001,resp.json().get("code"))
        self.assertEqual("用户名或密码错误",resp.json().get("maeeage"))
    def test_login_03(self):
        resp = requests.post(url='http://ihrm2-test.itheima.net/api/sys/login',
                             headers={"Content-Type": "application/json"},
                             json={"mobile": "13888800002", "password": "1234567"})
        self.assertEqual(200,resp.status_code)
        self.assertEqual(False,resp.json().get("success"))
        self.assertEqual(20001,resp.json().get("code"))
        self.assertEqual("用户名或密码错误",resp.json().get("maeeage"))
    def test_login_04(self):
        resp = requests.post(url='http://ihrm2-test.itheima.net/api/sys/login',
                             headers={"Content-Type": "application/json"},
                             json={"mobile": "null", "password": "1234567"})
        self.assertEqual(200,resp.status_code)
        self.assertEqual(False,resp.json().get("success"))
        self.assertEqual(20001,resp.json().get("code"))
        self.assertEqual("用户名或密码错误",resp.json().get("maeeage"))